﻿using ProductMonitor.OpCommand;
using ProductMonitor.UserControls;
using ProductMonitor.ViewModels;
using ProductMonitor.Views;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ProductMonitor
{

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainWindowVM mainWindowVM = new MainWindowVM();
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = mainWindowVM;
        }

        void ShowDetailUC()
        {
            WorkShopDataUC workShopDetailUC = new WorkShopDataUC();
            mainWindowVM.MonitorUC = workShopDetailUC;

            ////动画效果由下而上
            //ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(0,50,0,-50),new Thickness(0,0,0,0),new TimeSpan(0,0,0,0,40000));

            //DoubleAnimation doubleAnimation = new DoubleAnimation(0,1,new TimeSpan(0,0,0,0,400));

            //Storyboard.SetTarget(thicknessAnimation, workShopDetailUC);
            //Storyboard.SetTarget(doubleAnimation, workShopDetailUC);

            //Storyboard.SetTargetProperty(thicknessAnimation,new PropertyPath("Margin"));
            //Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Opacity"));

            //Storyboard storyboard = new Storyboard();
            //storyboard.Children.Add(thicknessAnimation);
            //storyboard.Children.Add(doubleAnimation);
            //storyboard.Begin();
        }

        public Command ShowDetailCmm
        {
            get {

                return new Command(ShowDetailUC);
            }
        }

        void GoBack()
        {
            MonitorUC monitorUC = new MonitorUC();
            mainWindowVM.MonitorUC = monitorUC;
        }

        public Command GoBackMonitorUCCmm
        {
            get
            {

                return new Command(GoBack);
            }
        }

        private void btnMin_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            //this.close();
            Environment.Exit(0);
        }

        //弹出配置窗口
        private void ShowSettingWindow()
        { 
          Setting setting = new Setting() { Owner = this };
            setting.ShowDialog();
        }

        public Command ShowSettingCmm {
            get {
                return new Command(ShowSettingWindow);
            }
        }
    }
}